/*
    fracgen-c : Fractal Generator (using concurrency)
    Copyright (C) 2010 Arpit Sud, Sri Teja Basava & Sidartha Gracias

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

package fractal;

import util.Complex;
import complexPlane.Axes;

public abstract class EscapeTimeFractal extends Fractal
{
	public static final int[] DEFAULT_COLORS =
	{ 	
		0xFFFFFF,  
		0x00EE00,
		0x00DD00,
		0x00CC00,
		0x00BB00,
		0x00AA00,
		0x008800,
		0x006600,
		0x004400,
		0x002200
	};
	
	/* limit --
	 *   whenever the magnitude of the fractal equation goes above this limit,
	 *   we declare it as having diverged
	 */
	protected final double _limit; 
	
	/* number of iterations --
	 *   if the fractal equation doesn't diverge in this many iterations,
	 *   we declare it as having converged
	 */
	protected final int _numIterations;
	
	/* colors for colored representation --
	 *   a color at a higher index specifies color for divergence at
	 *   higher number of iterations; convergence is always colored black
	 */
	protected final int[] _colors;
	
	public EscapeTimeFractal(Axes axes, double limit, int numIterations)
	{
		super(axes);
		
		_limit = limit;
		_numIterations = numIterations;
		_colors = DEFAULT_COLORS;
	}
	
	public EscapeTimeFractal(Axes axes, double limit, int numIterations, int[] colors)
	{
		super(axes);
		
		if (colors == null)
			throw new IllegalArgumentException();
		
		_limit = limit;
		_numIterations = numIterations;
		_colors = colors;
	}
	
	public abstract int getBW(Complex c);
	
	public abstract int getColor(Complex c);
}
